package cn.yunhe.biz;

import cn.yunhe.bean.Page;
import cn.yunhe.bean.Travel;
import cn.yunhe.dao.TravelMapper;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TravelService {

    SqlSession session=SqlSessionFactoryUtil.getSqlSession();
    TravelMapper travelMapper=session.getMapper(TravelMapper.class);
    //展示全部游记
    public List<Travel> getAllTravel(){
        return travelMapper.getAllTravel();
    }
    //分页展示部分游记
    public List<Travel> getTravelByPages(Page page){
        return travelMapper.getTravelByPages(page);
    }
    //获得游记总条数
    public int getTravelCount(){return travelMapper.getTravelCount();}

    //通过季节浏览游记
    public List<Travel> getTravelByKeyWord(String keyword){
        return travelMapper.getTravelByKeyWord(keyword);
    }

    public int addTravel(Travel travel){
        int flag=travelMapper.addTravel(travel);
        session.commit();
        return  flag;

    }
    public List<Travel> getExcellentTravel(){
        return travelMapper.getExcellentTravel();
    }


}

